package cn.okcmd.myquartz.quartz.schedulers;

import cn.okcmd.myquartz.quartz.jobs.Task1Job;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * create by caoqg on 2021/7/27
 * 功能说明:
 */
@Configuration
public class Task1Sch {

    @Bean
    public JobDetail detail() {
        JobDetail jobDetail = JobBuilder.newJob(Task1Job.class)
                .withIdentity("task1", "task1group")
                .withDescription("task1").storeDurably().build();
        return jobDetail;
    }

    @Bean
    public Trigger trigger() {
        CronScheduleBuilder cronSchedule = CronScheduleBuilder.cronSchedule("1/1 * * * * ?");
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .forJob(detail())
                .withIdentity("task1", "task1group")
                .withDescription("task1")
                .withSchedule(cronSchedule).build();
        return trigger;
    }

}
